﻿using System.Collections.Generic;
using System.Text;
using System;

namespace FuzzScript
{
    internal class SymbolTable
    {

        private SymbolTable(){}

        private static SymbolTable m_Instance = null;

        internal static SymbolTable Instance
        {
            get
            {
                if(m_Instance==null)
                    m_Instance= new SymbolTable();

                return m_Instance;
            }
        }


        private Dictionary<string, INode> m_Symbols = new Dictionary<string, INode>();

        internal void Put(string p_sName, INode p_sNode)
        {
            m_Symbols.Add(p_sName.ToUpper(), p_sNode);
        }


        internal INode Get(string p_sName)
        {
            return m_Symbols[p_sName.ToUpper()];
        }

        internal bool Contains(string p_sName)
        {
            return m_Symbols.ContainsKey(p_sName.ToUpper());
        }

        internal static string AttributeVariableInput(string p_sVariableName)
        {
            return "m_InputVariable_" + p_sVariableName;
        }


        internal static string AttributeVariableOutput(string p_sVariableName)
        {
            return "m_OutputVariable_" + p_sVariableName;
        }

        /// <summary>
        /// returns the name of a set attribute
        /// </summary>
        internal static string AttributeFuzzySet(string p_sVariableName, string p_sSetName)
        {
            return "m_Set_" + p_sVariableName.ToUpper() + "_" + p_sSetName.ToUpper();
        }

        internal static string AttributeVariableUpperLimit(string p_sVariableName)
        {
            return "m_d" + p_sVariableName.ToUpper() + "_UpperLimit";
        }

        internal static string AttributeVariableLowerLimit(string p_sVariableName)
        {
            return "m_d" + p_sVariableName.ToUpper() + "_LowerLimit";
        }

        internal static string MethodPredicate(string p_sPredicateName)
        {
            return "Predicate_" + p_sPredicateName.ToUpper();
        }

        internal static string AttributePredicateValue(string p_sPredicateName)
        {
            return "m_dPredicate_" + p_sPredicateName.ToUpper();
        }

        /// <summary>
        /// returns the name the attribute of the output set connected to a fuzzy variable
        /// </summary>
        internal static string AttributeOutputVariableSet(string p_sVariableName)
        {
            return "m_OutSet_" + p_sVariableName.ToUpper();
        }

        internal static string AttributeSetDOM(string p_sVariableName, string p_sSetName)
        {
            return "m_dDOM_" + p_sVariableName.ToUpper() + "_" + p_sSetName.ToUpper();
        }

        internal static string MethodSetVariableDOMMethod(string p_sVariableName)
        {
            return "Set_" + p_sVariableName.ToUpper() + "_DOM";
        }
    }
}
